#!/bin/bash

# 获取当前脚本的位置
shell_home="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# 切换到脚本的位置
cd $shell_home

source /etc/profile

# 获取时间参数
ds=$1

# 执行建表语句的sql
#hive -f ../hive_ddl/ads_in_station_day_top.sql
#
#hive -f ../hive_dql/ads_in_station_day_top.sql -d ds=${ds}

# 创建clickhouse表
# CREATE TABLE IF NOT EXISTS szt_ads.ads_in_station_day_top(day String,station String,count String,ds String)ENGINE = MergeTree ORDER BY ds PARTITION BY ds
clickhouse-client \
--port 9001 \
--user default \
--password 123456 \
--query "CREATE TABLE IF NOT EXISTS szt_ads.ads_in_station_day_top(day String,station String,count String,ds String)ENGINE = MergeTree ORDER BY ds PARTITION BY ds;"

# 执行datax脚本同步数据
datax.py -p "-Dds=${ds}" ../datax_jsons/ads_in_station_day_top.json